package com.lcz.manage.distribute;

import java.math.BigDecimal;

import static java.math.BigDecimal.ROUND_HALF_DOWN;

public class DistributeBean implements Comparable<DistributeBean>{

    private int count;

    private final int weight;

    private final String bizId;

    public DistributeBean(int weight,String bizId) {
        this.count = 1;
        this.weight = weight;
        this.bizId = bizId;
    }

    public DistributeBean(int count,int weight,String bizId) {
        this.count = count;
        this.weight = weight;
        this.bizId = bizId;
    }

    public void increase() {
        this.count += 1d;
    }

    public void increase(double increment) {
        this.count += increment;
    }

    public BigDecimal getPrority() {
        return new BigDecimal(weight).divide(new BigDecimal(count), 10, ROUND_HALF_DOWN);
    }

    @Override
    public int compareTo(DistributeBean o) {
        return this.getPrority().compareTo(o.getPrority());
    }

    public String getBizId() {
        return bizId;
    }

}